package netty.protobuf;

import com.google.protobuf.InvalidProtocolBufferException;

public class ProtobufTest {
    public static void main(String[] args) throws InvalidProtocolBufferException {
        // 执行代码生成DataInfo对象
        // >protoc --java_out=src/main/java src/protobuf/Student.proto
        DataInfo.Student student = DataInfo.Student.newBuilder().
                setName("张三").setAge(23).setAddress("北京").build();

        byte[] toByteArray = student.toByteArray();
        DataInfo.Student parseFrom = DataInfo.Student.parseFrom(toByteArray);
        System.out.println(parseFrom.getName());
        System.out.println(parseFrom.getAddress());
        System.out.println(parseFrom.getAge());
    }
}
